package com.labofjet.blogv3.dao;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import com.labofjet.blogv3.model.Artical;

public interface IArticalDao extends JpaRepository<Artical, Long> {

	/**
	 * 根据等级查找文章，按等级倒叙排，按时间倒叙排
	 * 
	 * @param level
	 * @return
	 */
	Page<Artical> findByLevelInAndIsDelete(
			List<Integer> level, boolean isDelete, Pageable pageable);

	/**
	 * 根据关键字获取文章 包含标题，简介，正文，作者
	 * 
	 * @param keyword
	 * @param start
	 * @param numPerPage
	 * @return
	 */
	Page<Artical> findByTitleLikeOrIntroductionLikeOrRawContentLikeOrAuthor_UserNameLikeAndIsDelete(
			String keyword, String keyword2, String keyword3, String keyword4, boolean isDelete,
			Pageable pageable);

	/**
	 * 根据标签查询文章
	 * @param keyword
	 * @param isDelete
	 * @param pageRequest
	 * @return
	 */
	Page<Artical> findByCategories_ContentAndIsDelete(String keyword, boolean isDelete, Pageable pageable);
}